import axios from 'axios'
// import router from '@/router'
import { getToken } from '@/utils/storage'

const request = axios.create({
  baseURL: 'http://121.199.51.160:8080/',
  timeout: 5000
})

// 请求拦截器
request.interceptors.request.use(
  function (config) {
    config.headers.Authorization = getToken()
    // console.log(config)
    return config
  },
  function (error) {
    // console.log(error)
    return Promise.reject(error)
  }
)

// 响应拦截器
request.interceptors.response.use(
  function (response) {
    // console.log(response)
    return response.data
  },
  function (error) {
    // console.log('error:', error)
    return Promise.reject(error)
  }
)

export default request
